package lock.demo1;

public class DeadLock implements Runnable{
    private int i=0;

    @Override
    public void run() {
        while (true){
            if(i%2==0){
                synchronized(LockA.lockA){
                    System.out.println("偶数-->"+"lockA");
                    synchronized (LockB.lockB){
                        System.out.println("偶数-->"+"lockB");
                    }
                }
            }else{
                synchronized(LockB.lockB){
                    System.out.println("奇数-->"+"lockB");
                    synchronized (LockA.lockA){
                        System.out.println("奇数-->"+"lockA");
                    }
                }
            }
            i++;
        }

    }
}
